Create New Module
This guide outlines how to add a new module to the project using baselines convention plugins.
1. Choose the Layer
Determine where your module belongs to maintain architectural separation:
| Layer | Purpose |
|---|---|
ui | Feature screens, navigation, theming. |
domain | Business logic, use-case orchestration, rules. |
data | Repository implementations, network, database. |
toolkit | Reusable utilities, DI, logging, crypto, etc. |
Action: Create a directory under the chosen layer (e.g., ui/profile).
2. Configure the Module
Choose the type of module you are building below.
Note: For both options, register the new module in
settings.gradle.kts, e.g.include(":ui:profile").
Namespaces are derived from BuildConfig.NAMESPACE in build-logic/convention/src/main/kotlin/io/baselines/gradle/BuildConfig.kt
and the module path. For example, a generated namespace of com.example.myapp and :ui:profile produce com.example.myapp.ui.profile.
Path segments are lowercased and hyphens are removed, so :ui:design-system uses the suffix .ui.designsystem.
For shared modules with DI contributions, also add the module to commonMain.dependencies in app/multiplatform/build.gradle.kts.
Apply alias(libs.plugins.baselines.di) in modules that use Metro.
For modules with unit tests, add alias(libs.plugins.baselines.testing.unit) to the plugins block.
It configures test dependencies and Android unit/host tests for either module type.
🅰️ Option A: Multiplatform Module (Android + iOS)
Standard choice for most logic and UI.
1. Create build.gradle.kts
Create the file inside your new directory and paste the following content.
kotlin1plugins {2 alias(libs.plugins.baselines.multiplatform.library)3 // Only needed if this module contains UI/Compose code4 alias(libs.plugins.baselines.compose)5}67// Define dependencies8kotlin {9 sourceSets {10 commonMain.dependencies {11 // Shared dependencies12 }13 androidMain.dependencies {14 // Android specific15 }16 iosMain.dependencies {17 // iOS specific18 }19 }20}
2. Create Folder Structure
Create the source folders matching your generated namespace.
<namespace-path> replaces dots with directory separators; for example, com.example.myapp becomes com/example/myapp:
text1📂 src2 ┣ 📂 commonMain/kotlin/<namespace-path>/ui/profile3 ┣ 📂 androidMain/kotlin/<namespace-path>/ui/profile4 ┗ 📂 iosMain/kotlin/<namespace-path>/ui/profile
🅱️ Option B: Android-Only Module
Use for platform-specific features (e.g., Google Services, Camera, Splash).
1. Create build.gradle.kts
Create the file inside your new directory and paste the following content.
kotlin1plugins {2 alias(libs.plugins.baselines.android.library)3 // Only needed if this module contains UI/Compose code4 alias(libs.plugins.baselines.compose)5}67// Define dependencies8dependencies {9 // Android dependencies10}
2. Create Folder Structure Create the standard Android source folder matching your namespace:
text1📂 src2 ┗ 📂 main/kotlin/<namespace-path>/ui/profile
Compose Resources
The Compose convention plugin configures src/commonMain/composeResources and generates a module-local Res class in the derived namespace.
It also reads compose-stability.conf from the project root. Keep stability declarations consistent with the actual types.